using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

/// <summary>
/// Summary description for DALChangePassword
/// </summary>
public class DALChangePassword
{
    /// <summary>
    /// Get the password of the logged in user
    /// </summary>
    /// <returns>Password</returns>
	public static string GetPassword(string UserName)
	{
        SqlCommand command = DAL.CreateCommand();
        command.Parameters.AddWithValue("@UserName", UserName);
        command.CommandText = SQL.GetPassword;
        SqlDataReader reader = DAL.ExecuteReader(command);
        if (reader.Read())
        {
            string Password = reader.GetString(0);
            return Password;
        }
        return null;
	}

    /// <summary>
    /// Update the password
    /// </summary>
    public static bool UpdatePassword(string Password, string UserName)
    {
        SqlCommand command = DAL.CreateCommand();
        command.Parameters.AddWithValue("@Password", Password);
        command.Parameters.AddWithValue("@UserName", UserName);
        command.CommandText = SQL.UpdatePassword;
        if (DAL.ExecuteNonQuery(command) > 0)
        {
            return true;
        }
        return false;
    }
}
